package com.san.hkhospital.service.impl;

import com.san.hkhospital.vo.Search1;
import com.san.hkhospital.vo.examineTableVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.san.hkhospital.entity.ExamineExample;
import com.san.hkhospital.entity.Examine;
import com.san.hkhospital.mapper.ExamineMapper;
import com.san.hkhospital.service.ExamineService;
import org.springframework.transaction.annotation.Transactional;

/**
 * ClassName:ExamineServiceImpl
 * PackageName:com.san.hkhospital.service.impl
 * Description:
 *
 * @Author:yy
 * @CreatedAt:2024/11/13 14:38
 * 
 */
 
 
@Service
@Transactional
public class ExamineServiceImpl implements ExamineService{

    @Resource
    private ExamineMapper examineMapper;

    @Override
    public long countByExample(ExamineExample example) {
        return examineMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(ExamineExample example) {
        return examineMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer exaId) {
        return examineMapper.deleteByPrimaryKey(exaId);
    }

    @Override
    public int insert(Examine record) {
        return examineMapper.insert(record);
    }

    @Override
    public int insertSelective(Examine record) {
        return examineMapper.insertSelective(record);
    }

    @Override
    public List<Examine> selectByExample(ExamineExample example) {
        return examineMapper.selectByExample(example);
    }

    @Override
    public Examine selectByPrimaryKey(Integer exaId) {
        return examineMapper.selectByPrimaryKey(exaId);
    }

    @Override
    public int updateByExampleSelective(Examine record,ExamineExample example) {
        return examineMapper.updateByExampleSelective(record,example);
    }

    @Override
    public int updateByExample(Examine record,ExamineExample example) {
        return examineMapper.updateByExample(record,example);
    }

    @Override
    public int updateByPrimaryKeySelective(Examine record) {
        return examineMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Examine record) {
        return examineMapper.updateByPrimaryKey(record);
    }

    @Override
    public Examine find(Integer id) {
        return examineMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<examineTableVO> findAll() {
      return  examineMapper.findAll();
    }

    @Override
    public boolean add(Examine examine) {
        int i = examineMapper.insertSelective(examine);
        return i>0?true:false;
    }

    @Override
    public boolean update(Examine examine) {
        // 修改状态
        if(examine.getStateId()==12){
            return false;
        }else if(examine.getStateId()==10){
            examine.setStateId(11);
        }else if(examine.getStateId()==11){
            examine.setStateId(12);
        }
        int i = examineMapper.updateByPrimaryKeySelective(examine);
        return i>0?true:false;
    }

    @Override
    public List<examineTableVO> search(Search1 search1) {
        return examineMapper.search(search1);
    }

}
